#—*—coding:utf-8 -*-
#@Time        :2022/7/16 9:49
#@Author      :dhx
#@File        :create_could_collect1_page.py
# @Software: PyCharm
from time import sleep

from selenium.webdriver.common.by import By
from pages.finance_page import FinancePage

from pages.base_pageage import BasePage
class TestCouldPay(FinancePage):
    url='http://192.168.3.133/crm/index.php?m=finance&a=add&t=payables'
    name_locator = (By.ID, 'name')  # 定位收款名
    customer_locator = (By.ID, 'customer')  # 客户
    option_customer = (By.XPATH, '//*[@id="datas"]/tr/td[1]/input[1]')  # 选择第一个
    ok_locator = (By.XPATH, '/html/body/div[7]/div[3]/div/button[1]')
    people_locator = (By.ID, 'owner_name')  # 负责人
    option_person_locator = (By.XPATH, '//*[@id="d_content"]/tr[1]/td[1]/input')  # 选择负责人
    ok_person_locator = (By.XPATH, '/html/body/div[9]/div[3]/div/button[1]/span')  # 点击保存
    price_locator = (By.ID, 'price')  # 金额
    time_locator = (By.ID, 'pay_time')  # 时间
    description = (By.XPATH, '/html/body/div[5]/div[2]/div/form/table/tbody/tr[9]/td[2]/textarea')  # 描述
    save_locator = (By.XPATH, '/html/body/div[5]/div[2]/div/form/table/tfoot/tr/td[2]/input[1]')  # 保存

    def pay_name(self,name):
        """输入应收款名"""
        self.driver.find_element(*self.name_locator).send_keys(name)
        sleep(1)
    def modif_name(self):
        """修改应收款名"""
        self.driver.find_element(*self.name_locator).clear()
        sleep(1)
        self.driver.find_element(*self.name_locator).send_keys("花花")
    def custom(self):
        """选择客户"""
        self.driver.find_element(*self.customer_locator).click()
        sleep(1)
    def first_custom(self):
        """选择第一个客户"""
        self.driver.find_element(*self.option_customer).click()
        sleep(1)
    def option_custom(self):
        """点击保存"""
        self.driver.find_element(*self.ok_locator).click()
        sleep(1)
    def option_person(self):
        """选择负责人"""
        self.driver.find_element(*self.people_locator).click()
        sleep(1)
    def first_option(self):
        """勾选第一个"""
        self.driver.find_element(*self.option_person_locator).click()
        sleep(1)
    def save_person(self):
        """保存"""
        self.driver.find_element(*self.ok_person_locator).click()
        sleep(1)
    def price_pay(self):
        """输入金额"""
        self.driver.find_element(*self.price_locator).send_keys("2000")
        sleep(1)
    def time_pay(self):
        """输入收款时间"""
        self.driver.find_element(*self.time_locator).send_keys("2022-07-02")
        sleep(1)
    def desc(self):
        """输入描述"""
        self.driver.find_element(*self.description).send_keys("描述")
        sleep(1)
    def f_save(self):
        """保存"""
        self.driver.find_element(*self.save_locator).click()
        sleep(1)













